package com.mym.test;

import java.util.Scanner;

/**
 * @author miao
 * @version 1.0
 * @date 2025/4/10 11:48
 * @description
 */
public class FlowerImpl implements Flower {
    // 1. 准备一个二维数组FLOWER_LIST
    public static final String[][] FLOWER_LIST = new String[10][7];

    // 准备一个键盘输入对象
    public static final Scanner INPUT = new Scanner(System.in);

    // 2. 使用静态代码块为FLOWER_LIST初始化5条数据
    static {
        FLOWER_LIST[0] = new String[]{"1001", "金色海岸-香饼玫瑰", "10", "318.0", "2016-12-12", "王二妮", ""};
        FLOWER_LIST[1] = new String[]{"1002", "出行永不变-白眉滚", "99", "538.0", "2016-12-20", "张馨予", ""};
        FLOWER_LIST[2] = new String[]{"1003", "梦里花开-紫色结棍", "40", "148.0", "2016-12-24", "王二妮", "没播入睡"};
        FLOWER_LIST[3] = new String[]{"1004", "心花怒放-粉象百合", "120", "188.0", "2016-12-26", "王二妮", "内层应灰色"};
        FLOWER_LIST[4] = new String[]{"1005", "知青村-无声的爱", "1000", "219.0", "2016-12-18", "张馨予", "捂脸"};
    }

    @Override
    public void FlowerCha() {
        for (String[] ziList : FLOWER_LIST) {
            if (ziList[0] != null) {
                System.out.println(ziList[0] + "\t" + ziList[1] + "\t\t" + ziList[2] + "\t" + ziList[3] + "\t" + ziList[4] + "\t\t" + ziList[5] + "\t" + ziList[6]);
            }
        }

    }

    @Override
    public void FlowerXiu() {
        System.out.println("请输入销售编号");
        Scanner scanner = new Scanner(System.in);
        String id = scanner.nextLine();
        //判断输入的id是否存在
        boolean flag = false;
        for (String[] strings : FLOWER_LIST) {
            if (id.equals(strings[0])) {
                flag = true;
                break;
            }
        }
        if (flag = false) {
            System.out.println("您输入的编号错误");
        }
        System.out.println("查看订单详情");
        for (String[] ziList : FLOWER_LIST) {
            if (id.equals(ziList[0])) {
                System.out.println(ziList[0] + "\t" + ziList[1] + "\t\t" + ziList[2] + "\t" + ziList[3] + "\t" + ziList[4] + "\t\t" + ziList[5] + "\t" + ziList[6]);
            }
        }
        while (true) {
            System.out.println("请输入你要修改后的鲜花名称");
            String name = scanner.nextLine();
            for (String[] ziList : FLOWER_LIST) {
                if (id.equals(ziList[0])) {
                    ziList[1] = name;
                }
            }
            System.out.println("请输入你要修改后的销售数量");
            String num = scanner.nextLine();
            for (String[] ziList : FLOWER_LIST) {
                if (id.equals(ziList[0])) {
                    ziList[2] = num;
                }
            }
            System.out.println("请输入你要修改后的销售价格");
            String num1 = scanner.nextLine();
            for (String[] ziList : FLOWER_LIST) {
                if (id.equals(ziList[0])) {
                    ziList[3] = num1;
                }
            }
            System.out.println("请输入你要修改后的销售日期");
            String num2 = scanner.nextLine();
            for (String[] ziList : FLOWER_LIST) {
                if (id.equals(ziList[0])) {
                    ziList[4] = num2;
                }
            }
            System.out.println("请输入你要修改后的销售员");
            String num3 = scanner.nextLine();
            for (String[] ziList : FLOWER_LIST) {
                if (id.equals(ziList[0])) {
                    ziList[5] = num3;
                }
            }
            System.out.println("请输入你要修改后的备注");
            String num4 = scanner.nextLine();
            for (String[] ziList : FLOWER_LIST) {
                if (id.equals(ziList[0])) {
                    ziList[6] = num4;
                }
            }
            System.out.println("是否确定要修改（y/s）");
            String s = scanner.nextLine();
            for (String[] ziList : FLOWER_LIST) {
                if (s.equals("y")) {
                    System.out.println("修改成功");
                    System.out.println(ziList[0] + "\t" + ziList[1] + "\t\t" + ziList[2] + "\t" + ziList[3] + "\t" + ziList[4] + "\t\t" + ziList[5] + "\t" + ziList[6]);
                } else {
                    break;
                }
            }
        }
    }

    @Override
    public void FlowerShan() {
        Scanner scanner = new Scanner(System.in);
        String id = scanner.nextLine();
        int index = 0;
        for (String[] ziList : FLOWER_LIST) {
            //判断输入的id是否存在
            boolean flag = false;
            for (String[] strings : FLOWER_LIST) {
                if (id.equals(strings[0])) {
                    flag = true;
                    break;
                }
            }
            if (flag = false) {
                System.out.println("您输入的编号错误");
            }

        }
        for (int i = 0; i < FLOWER_LIST.length; i++) {
            for (String[] ziList : FLOWER_LIST) {
                if (id.equals(ziList[0])) {
                    index = i;
                    break;
                }
            }
        }
        for (int i = index+1; i < FLOWER_LIST.length; i++) {
            FLOWER_LIST[i-1]=FLOWER_LIST[i];
        }

    }

}



